package com.ror.java.se.array;

public class Demo02Reverse {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5,};
        int[] res = getReverse(arr);
        System.out.println("Before:");
        for (int i : arr) {
            System.out.print(i + " ");
        }
        System.out.println();
        System.out.println("After:");
        for (int j : res) {
            System.out.print(j+" ");
        }
        System.out.println();
    }

    public static int[] getReverse(int[] arr) {
        int[] res = new int[arr.length];
        for (int i = 0, j = arr.length - 1; i < arr.length; i++, j--) {
            res[i] = arr[j];
        }
        return res;
    }

}
